# 给定一个包含红色、白色和蓝色的数组 nums，请排序该数组
def solve(nums: list[int]):
    low, mid, high = 0, 0, len(nums) - 1
    
    while mid <= high:
        if nums[mid] == 0:
            nums[low], nums[mid] = nums[mid], nums[low]
            low += 1
            mid += 1
        elif nums[mid] == 2:
            nums[mid], nums[high] = nums[high], nums[mid]
            high -= 1
        else:
            mid += 1
            
    return nums

if __name__ == "__main__":
    print(solve([2, 0, 1, 2, 1, 0, 2, 1, 1, 0]))  # 输出 [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]
